#pragma once
#include<iostream>
#include<cstdlib>
#include<time.h>
#include<vector>
#include"Card.h"
using namespace std;

//#include"Cardgame.h"
#ifndef POKER_H
#define POKER_H

class Card;
//全局函数整副牌的牌数
const int g_Size = 54;
//全局函数单色牌数
const int g_Singlecolor = 13;
const int color_num = 4;

class Poker
{
	//设定cardgame为友元类，以便操作poker类的数据成员
	//friend class Cardgame;
public:
	//声明poker类的构造函数，初始化牌的数量
	Poker();
    vector<Card> getPoker();
    void Createpoker();
    //进行洗牌操作
	void Shufflepoker();
	//将整副牌进行格式化输出
    void Pop_poker();
    void print();
private:
    vector<Card>poker;
};
#endif

//声明poker类的构造函数，初始化牌的数量
Poker::Poker()
{
    Createpoker();
}
void Poker::Createpoker()
{
    int index = 1;
    //为了是牌从1开始数，便于后续操作
    poker.resize(g_Size + 1);
    for (int i = 1; i <= g_Singlecolor; i++)
    {
        for(int j = 1; j <= color_num; j++)
        {
            poker[index++].setCard(i, j);
        }    
    }
    poker[index++].setCard(14, 5);
    poker[index++].setCard(14, 6);
}
//进行洗牌操作
void Poker::Shufflepoker()
{
    //定义随机数
    srand(time(0));
	//对整副牌顺序进行重新排列
    for (int i = 1; i <= g_Size; i++)
    {
		int index = rand() % g_Size + 1;
		Card t_card = poker[i];
		poker[i].setCard(poker[index].getCardnum(),poker[index].getCardcolor());
    	poker[index].setCard(t_card.getCardnum(), t_card.getCardcolor());
	}  
}
vector<Card> Poker::getPoker()
{
    return poker;
}
void Poker::Pop_poker()
{
    poker.pop_back();
}
//将整副牌进行格式化输出
void Poker::print()
{
    for (int i = 1; i <= g_Size; i++)
    {
        poker[i].printCard();
		if(i%4==0)
		{
			cout << endl;
		}
    }
}
